import Vue from 'vue'
import Router from 'vue-router'
import login from '@/components/login'
import layout from '@/components/layout'
import home from '@/components/home'
import area from '@/components/sys/area'
import dict from '@/components/sys/dict'
import menu from '@/components/sys/menu'
import role from '@/components/sys/role'
import user from '@/components/sys/user'
import userinfo from '@/components/sys/userinfo'
import logs from '@/components/sys/logs'
//填报设置
import fillset from '@/components/fillset/set.vue'
import fillcreat from '@/components/fillset/creat'


//填报
import promotion from '@/components/fillin/potPromotion'
import prosecution from '@/components/fillin/potProsecution'
import saleStorege from '@/components/fillin/potSaleStorege'
import seasonProduct from '@/components/fillin/potSeasonProduct'
import potSeed from '@/components/fillin/potSeed'
import ProjectImple from '@/components/fillin/potProject'
import yearProduct from '@/components/fillin/potYearProduct'


//审核
import rpromotion from '@/components/review/potPromotion'
import rprosecution from '@/components/review/potProsecution'
import rsaleStorege from '@/components/review/potSaleStorege'
import rseasonProduct from '@/components/review/potSeasonProduct'
import rpotSeed from '@/components/review/potSeed'
import rProjectImple from '@/components/review/potProject'
import ryearProduct from '@/components/review/potYearProduct'

//统计
import spromotion from '@/components/statistics/potPromotion'
import sprosecution from '@/components/statistics/potProsecution'
import ssaleStorege from '@/components/statistics/potSaleStorege'
import sseasonProduct from '@/components/statistics/potSeasonProduct'
import spotSeed from '@/components/statistics/potSeed'
import sProjectImple from '@/components/statistics/potProject'
import syearProduct from '@/components/statistics/potYearProduct'

import store from '../store/store'
import vueext from '../extended/vueext'

import axios from '../config'//默认http请求配置
//引入vue扩展方法
Vue.use(vueext)
Vue.use(Router)


const routes = [
  { path: '/', name: '登录', component: login },
  {
    path: '/layout', name: '框架', component: layout, children: [
      { path: '/home', name: '首页', meta: { icon: "ios-home-outline" }, component: home },
      { path: '/sys/area', name: '行政区划管理', meta: { icon: "map" }, component: area },
      { path: '/sys/dict', name: '数据字典', meta: { icon: "gear-b" }, component: dict },
      { path: '/sys/menu', name: '菜单管理', meta: { icon: "ios-list-outline" }, component: menu },
      { path: '/sys/role', name: '角色管理', meta: { icon: "briefcase" }, component: role },
      { path: '/sys/user', name: '用户管理', meta: { icon: "person-stalker" }, component: user },
      { path: '/sys/userinfo', name: '个人信息修改', meta: { icon: "person-stalker" }, component: userinfo },
      { path: '/sys/logs', name: '日志管理', meta: { icon: "clipboard" }, component: logs },
      { path: '/fillset/set', name: '填报设置', meta: { icon: "settings" }, component: fillset },
      { path: '/fillset/creat', name: '填报生成', meta: { icon: "social-buffer" }, component: fillcreat },
      { path: '/fillin/potPromotion', name: '（七）马铃薯技术推广机构及人员相关情况统计表', meta: { icon: "social-buffer" }, component: promotion },
      { path: '/fillin/potProsecution', name: '（六）马铃薯生产经营实体及相关情况', meta: { icon: "social-buffer" }, component: prosecution },
      { path: '/fillin/potSaleStorege', name: '（五）马铃薯销售、存储与加工情况统计表', meta: { icon: "social-buffer" }, component: saleStorege },
      { path: '/fillin/potSeasonProduct', name: '（二）各生产季马铃薯生产情况统计表', meta: { icon: "social-buffer" }, component: seasonProduct },
      { path: '/fillin/potSeed', name: '（三）马铃薯种薯生产情况统计表', meta: { icon: "social-buffer" }, component: potSeed },
      { path: '/fillin/potProject', name: '（四）马铃薯项目实施情况统计表', meta: { icon: "social-buffer" }, component: ProjectImple },     
      { path: '/fillin/potYearProduct', name: '（一）各品种马铃薯全年生产情况统计表', meta: { icon: "social-buffer" }, component: yearProduct },
      
      { path: '/review/potPromotion', name: '（七）马铃薯技术推广机构及人员相关情况统计表审核', meta: { icon: "social-buffer" }, component: rpromotion },
      { path: '/review/potProsecution', name: '（六）马铃薯生产经营实体及相关情况审核', meta: { icon: "social-buffer" }, component: rprosecution },
      { path: '/review/potSaleStorege', name: '（五）马铃薯销售、存储与加工情况统计表审核', meta: { icon: "social-buffer" }, component: rsaleStorege },
      { path: '/review/potSeasonProduct', name: '（二）各生产季马铃薯生产情况统计表审核', meta: { icon: "social-buffer" }, component: rseasonProduct },
      { path: '/review/potSeed', name: '（三）马铃薯种薯生产情况统计表审核', meta: { icon: "social-buffer" }, component: rpotSeed },
      { path: '/review/potProject', name: '（四）马铃薯项目实施情况统计表审核', meta: { icon: "social-buffer" }, component: rProjectImple },
      { path: '/review/potYearProduct', name: '（一）各品种马铃薯全年生产情况统计表审核', meta: { icon: "social-buffer" }, component: ryearProduct },

      { path: '/statistics/potPromotion', name: '（七）马铃薯技术推广机构及人员相关情况统计表汇总', meta: { icon: "social-buffer" }, component: spromotion },
      { path: '/statistics/potProsecution', name: '（六）马铃薯生产经营实体及相关情况汇总', meta: { icon: "social-buffer" }, component: sprosecution },
      { path: '/statistics/potSaleStorege', name: '（五）马铃薯销售、存储与加工情况统计表汇总', meta: { icon: "social-buffer" }, component: ssaleStorege },
      { path: '/statistics/potSeasonProduct', name: '（二）各生产季马铃薯生产情况统计表汇总', meta: { icon: "social-buffer" }, component: sseasonProduct },
      { path: '/statistics/potSeed', name: '（三）马铃薯种薯生产情况统计表汇总', meta: { icon: "social-buffer" }, component: spotSeed },
      { path: '/statistics/potProject', name: '（四）马铃薯项目实施情况统计表汇总', meta: { icon: "social-buffer" }, component: sProjectImple },
      { path: '/statistics/potYearProduct', name: '（一）各品种马铃薯全年生产情况统计表汇总', meta: { icon: "social-buffer" }, component: syearProduct },
      
    ]
  }
];
let router = new Router({
  routes
});

// 全局 before 钩子: 进入下一个路由前， 修改 Vuex 中的 breadcrumb 内容
router.beforeEach((to, from, next) => {
  var user = Vue.prototype.GetlocaStorage("potUserinfo");
  var userActions = Vue.prototype.GetlocaStorage("potUseractionlist");
  if (to.name !== '登录') {
    if (user !== null) {
      if (to.path !== '/home') {
        //面包削数据更新
        var BreadcrumbItem = new Object();
        BreadcrumbItem.RouterName = to.name;
        BreadcrumbItem.RouterUrl = to.path;
        BreadcrumbItem.RouterIcon = to.meta.icon;
        store.dispatch('updateBreadcrumb', BreadcrumbItem);
        //用户操作按钮权限列表数据更新
        var actionInfo = new Object();
        actionInfo.path = to.path;
        actionInfo.account = user.Account;
        actionInfo.list = userActions;
        store.dispatch('setActionList', actionInfo);
      } else {
        store.dispatch('desBreadcrumb');
      }
      next();
    } else {
      next({
        path: '/'
      })
    }
  } else {
    next();
  }
})
export default router;